/*
 * This file (MathNode.java) is protected by the GNU GPL licence (v2). 
 * Please read the license.txt attached for further informations. 
 * 
 */
package org.algoristes.alkwarel.script;

/**
 * A single math node
 * 
 * @author Xavier Gouchet
 * 
 */
public class MathNode {
	String mValue;

	/**
	 * Default constructor
	 * 
	 * @param value
	 *            value of the node
	 */
	public MathNode(String value) {
		mValue = value;
	}

	/**
	 * @see Object#toString()
	 */
	public String toString() {
		return mValue;
	}

	/**
	 * Evaluates the node value (as a number)
	 * 
	 * @return the node value
	 */
	public double eval() {
		if (mValue == null)
			return 0;
		if (mValue.length() == 0)
			return 0;
		return Double.parseDouble(mValue);
	}
}